Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';

    Ext.QuickTips.init();

    Ext.form.Field.prototype.msgTarget = 'side';
    //查询框
   var form1 = new Ext.form.FormPanel({
			title:'律师信息查询',
			labelSeparator :'：',//分隔符
			labelWidth : 80,//标签宽度
			bodyStyle:'padding:5',//表单边距
			frame : true,
			collapsible: true,
			height:100,
			width:window.screen.width-220,
			applyTo :'form1',
		
		
			items:[

				new Ext.form.TextField({
					fieldLabel : '律师姓名',
					id : 'lawyerName',
					name : 'lawyerName',
					width:(window.screen.width-320)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),

				new Ext.form.TextField({
					fieldLabel : '职位',
					id : 'positionName',
					name : 'positionName',
					width:(window.screen.width-320)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),
				new Ext.Button({
					text : '开始查询',
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					handler : submitMsg
				})
			]

		})
		
		//查询处理函数
	function submitMsg(){
		var lawyerName=Ext.getCmp("lawyerName").getValue();
		var positionName=Ext.getCmp("positionName").getValue();
		alert(lawyerName+positionName);
		
		 store = new Ext.data.JsonStore({
	url:"SearchLawyerInfo.jsj?lawyerName="+lawyerName+"&positionName="+positionName,
	totalProperty: 'totalCount',
    root: 'result',
	fields:["lawyerid","lawyername","birthtime","lawyersex","politicalstatus","businessnumber","businesyear","honestarchives","lawyerphone","educationallevel","identitynumber","annsurreginfo","positionname","graduateschool","lawyeremail"]
});
		store.reload({
			params:{
				start:0,
				limit:5
				}
			});
		var colModel = new Ext.grid.ColumnModel([//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "律师ID", width: 45, dataIndex: 'lawyerid', sortable: true},
				{header: "律师姓名", width: 75, dataIndex: 'lawyername', sortable: true},
				{header: "出生年月", width: 75, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'lawyersex', sortable: true},
				{header: "政治面貌", width: 75, dataIndex: 'politicalstatus', sortable: true},
				{header: "执业证号", width: 75, dataIndex: 'businessnumber', sortable: true},
				{header: "执业年限", width: 75, dataIndex: 'businesyear', sortable: true},
				{header: "诚信档案", width: 75, dataIndex: 'honestarchives', sortable: true},
				{header: "联系方式", width: 75, dataIndex: 'lawyerphone', sortable: true},
				{header: "文化程度", width: 75, dataIndex: 'educationallevel', sortable: true},
				{header: "身份证号", width: 75, dataIndex: 'identitynumber', sortable: true},
				{header: "年检注册情况", width: 75, dataIndex: 'annsurreginfo', sortable: true},
				{header: "职位名", width: 75, dataIndex: 'positionname', sortable: true},
				{header: "毕业院校", width: 75, dataIndex: 'graduateschool', sortable: true},
				{header: "邮箱", width: 75, dataIndex: 'lawyeremail', sortable: true},
				]);
				pagebar.bind(store);
				grid.reconfigure(store,colModel);
		grid.getView().refresh(true); 
		alert("okkkkkkkkkk");
	}
	
	
	

	
    //存储器
		var store = new Ext.data.JsonStore({
	url:"LawyerInfoRequest.jsj",
	totalProperty: 'totalCount',
	root: 'result',
	fields:["lawyerid","lawyername","birthtime","lawyersex","politicalstatus","businessnumber","businesyear","honestarchives","lawyerphone","educationallevel","identitynumber","annsurreginfo","positionname","graduateschool","lawyeremail"]
});
		store.load({
			params:{
				start:0,
				limit:5
				}
			});

	//创建工具栏组件
		var toolbar = new Ext.Toolbar([
			{text : '律师基本信息'},
			'-', 
			{
			text:'修改选定律师信息',
			handler:function(btn,pressed){
				modifyLawyerInfo();
			}
			},
			'-', 
			{
			text:'删除选定律师信息',
			handler:function(btn,pressed){
			}
			}
		]);
		
		
		//修改律师信息函数
		function modifyLawyerInfo(){
		var record=this.grid.getSelectionModel().getSelected();	
		alert("aaa");
			alert(record);
		}

		//分页工具栏
		var pagebar = new Ext.PagingToolbar({
			store : store,
			pageSize : 5,
			displayInfo : true,
			displayMsg : '第 {0} ~ {1} 条 共 {2} 条',
			emptyMsg : '当前没有记录'
		});
		//创建选择模式对象
	var cb = new Ext.grid.CheckboxSelectionModel()
	//创建Grid表格组件
	var grid = new Ext.grid.GridPanel({
			renderTo : 'grid-div',
			frame : true,
			tbar : toolbar,
			bbar : pagebar,
			trackMouseOver:true, //鼠标特效
			loadMask: true,    //是否显示正在加载
			store : store,
			height : 320,
			width : window.screen.width-220,
			stripeRows : true,
			autoScroll : true,
			viewConfig : {autoFill : true},
			sm : cb,
			columns: [//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "律师ID", width: 45, dataIndex: 'lawyerid', sortable: true},
				{header: "律师姓名", width: 75, dataIndex: 'lawyername', sortable: true},
				{header: "出生年月", width: 75, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'lawyersex', sortable: true},
				{header: "政治面貌", width: 75, dataIndex: 'politicalstatus', sortable: true},
				{header: "执业证号", width: 75, dataIndex: 'businessnumber', sortable: true},
				{header: "执业年限", width: 75, dataIndex: 'businesyear', sortable: true},
				{header: "诚信档案", width: 75, dataIndex: 'honestarchives', sortable: true},
				{header: "联系方式", width: 75, dataIndex: 'lawyerphone', sortable: true},
				{header: "文化程度", width: 75, dataIndex: 'educationallevel', sortable: true},
				{header: "身份证号", width: 75, dataIndex: 'identitynumber', sortable: true},
				{header: "年检注册情况", width: 75, dataIndex: 'annsurreginfo', sortable: true},
				{header: "职位名", width: 75, dataIndex: 'positionname', sortable: true},
				{header: "毕业院校", width: 75, dataIndex: 'graduateschool', sortable: true},
				{header: "邮箱", width: 75, dataIndex: 'lawyeremail', sortable: true},
				]
		});
		
		
});

